package com.mlk.core.component.page;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.plugins.PaginationInterceptor;

import lombok.Data;

/**
 * 分页属性配置类
 * 
 * @author trek
 *
 */
@Configuration
public class PagerConfig {

	/**
	 * 分页的基础信息
	 * 
	 * @author trek
	 *
	 */
	@Data
	public static class PagerProperties {

		private String pageName;

		private String limitName;

	}

	/**
	 * 向容器之中注入一个PagerConfig的组件
	 * 
	 * @return
	 */
	@Bean
	@ConfigurationProperties("pager")
	public PagerProperties pagerProperties() {
		return new PagerProperties();
	}
	
	/**
	 * 添加分页插件组件
	 * @return
	 */
	@Bean
	public PaginationInterceptor paginationInterceptor() {
		 PaginationInterceptor interceptor = new PaginationInterceptor();
		 // 开启本地分页功能
		 interceptor.setLocalPage(true);
		 return interceptor;
	}
}
